package com.dz.controller.manager;

import com.dz.bean.Rate;
import com.dz.service.RateService;
import com.dz.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/m/rate")
@CrossOrigin
public class RateController {
    @Autowired
    RateService rateService;

    @PostMapping("/add")
    public Result add(@RequestBody Rate rate) {
        boolean result = rateService.addRate(rate);
        return Result.success(result);
    }

    @GetMapping("/getRateByGuideId")
    public Result getRateByGuideId(@RequestParam Integer guideId) {
        Double result = rateService.getRateByGuideId(guideId);
        if (result == null){
            result = 0.0;
        }
        return Result.success(result);
    }
}
